Skip to content

refactor: use host for watcher#2200

Merged
JoshuaKGoldberg merged 9 commits intomainfrom
hosted-cli2
Mar 1, 2026
Merged

refactor: use host for watcher#2200
JoshuaKGoldberg merged 9 commits intomainfrom
hosted-cli2

Conversation

@lishaduck
Copy link
Copy Markdown
Member

@lishaduck lishaduck commented Jan 31, 2026

PR Checklist

Overview

❤️‍🔥

I don't remember if this works, I whipped this up on a 6-hour car ride to Oklahoma yesterday.

@vercel
Copy link
Copy Markdown

vercel bot commented Jan 31, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
flint Ready Ready Preview, Comment Feb 23, 2026 9:52pm

Request Review

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Jan 31, 2026

⚠️ No Changeset found

Latest commit: 4a6f499

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Comment on lines +12 to +15
export function findConfigFileName(host: LinterHost) {
const children = new Set(
host.readDirectory(host.getCurrentDirectory()).map((file) => file.name),
);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need the host to be async-first, blocking second. @auvred, is there a reason why the host is synchronous-first beyond that typescript is synchronous? Can we rename readDirectory to like readDirectorySync for ts and make readDirectory the promised version?

Also is there a reason getCurrentDirectory is a function? It's always constant. I really couldn't care less, if it's a style choice that's fine by me, but I'm mildly curious. Wouldn't it be more efficient (on a nano-optimization level ofc) to make it property?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need the host to be async-first, blocking second. @auvred, is there a reason why the host is synchronous-first beyond that typescript is synchronous? Can we rename readDirectory to like readDirectorySync for ts and make readDirectory the promised version?

Yeah, it's synchronous only because ts.sys is synchronous. Adding a pair of async methods sounds pretty reasonable to me. We probably won't gain much speed from using async versions, but it's nice to have IMO.

Also is there a reason getCurrentDirectory is a function? It's always constant. I really couldn't care less, if it's a style choice that's fine by me, but I'm mildly curious. Wouldn't it be more efficient (on a nano-optimization level ofc) to make it property?

Since our LinterHosts are interface-based and designed to be layered on top of one another, it's easier to have getCurrentDirectory as a function (some LinterHost implementation may choose to override its behavior dynamically)

@lishaduck
Copy link
Copy Markdown
Member Author

We really need a better way to do stacked PRs, this is stacked on #2199 so I have to keep this in draft but that stops it from showing up the review queue when this is equally ready for review... 🤔

}

export interface WatchDirectoryOptions extends WatchOptions {
recursive: boolean;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYT about making recursive an optional? pollingInterval is optional, so it would be nice to be consistent. However, if you made this for the sake of explicitness, I'm okay with that!

Copy link
Copy Markdown
Member Author

@lishaduck lishaduck Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you made this for the sake of explicitness, I'm okay with that!

Yeah, it was required before so I was sticking with that. I don't know enough about watching to know what it makes sense to default to (aka why is recursive: false even a thing?) so I'm not going to touch it.

If anyone else feels does strongly though, please let me know! I'm happy to change it.

Copy link
Copy Markdown
Member

@auvred auvred left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, I'm really positive about these changes!

Comment on lines +111 to +114
getFileTouchTimeSync() {
// TODO: uhh... this probably doesn't work amazingly
return Date.now();
},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on filing this as a followup

lishaduck and others added 3 commits February 14, 2026 12:45
I think Auvred's right here?
He's more right than me that's for sure.
Co-authored-by: auvred <61150013+auvred@users.noreply.github.com>
Co-authored-by: auvred <61150013+auvred@users.noreply.github.com>
Copy link
Copy Markdown
Member

@auvred auvred left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool 💥

@auvred auvred added the 1 approval One team member approved; we're now waiting for a second approval or for 2 business days to pass. label Feb 24, 2026
@barrymichaeldoyle barrymichaeldoyle added ready to merge 2+ team members approved; we're now waiting on the author to file followups and self-merge. and removed 1 approval One team member approved; we're now waiting for a second approval or for 2 business days to pass. labels Mar 1, 2026
Copy link
Copy Markdown
Collaborator

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hell yeah!!

@JoshuaKGoldberg JoshuaKGoldberg merged commit c504693 into main Mar 1, 2026
10 checks passed
@JoshuaKGoldberg JoshuaKGoldberg deleted the hosted-cli2 branch March 1, 2026 17:29
@lishaduck lishaduck mentioned this pull request Mar 11, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready to merge 2+ team members approved; we're now waiting on the author to file followups and self-merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants